<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>教练浏览|私教预约系统</title>
    <link href="../assets/css/bootstrap-grid.css" rel="stylesheet">
    <link href="../assets/css/font-awesome.css" rel="stylesheet">
    <link href="../assets/css/zoomslider.css" rel="stylesheet">
    <link href="../assets/css/swiper.css" rel="stylesheet">
    <link href="../assets/css/swipebox.css" rel="stylesheet">
    <link href="../assets/css/style-pink.css" rel="stylesheet">
    <link rel="stylesheet" href="../assets/css/jquery-ui.css">
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700%7CFira+Sans:400,500,600,700,800,900" rel="stylesheet">
    <script type="text/javascript" src="../assets/js/modernizr-2.6.2.min.js"></script>
</head>
<body>

<div>&ensp;</div>

<div class="container">
    <h1>我们的 <span class="someFront">教练</span></h1>
</div>

<div class="col-sm-4 col-sm-offset-10">
    <select class = "selectpicker someFront1" id = "inputSortType" title="请选择" onclick="sort()">
        <option value="1">经验排序</option>
        <option value="2">年龄排序</option>
        <option value="3">男教练</option>
        <option value="4">女教练</option>
    </select>
</div>

<div class="coaches coaches-inner">
    <div class="container">
        <div class="row" id="trainerPlace">

        </div>
    </div>
</div>

<section class="block-white">
    <div class="container">
        <div class="bg" style="background-image: url(../assets/images/_start-photo-pink.png);">
            <div class="content">
                <h3>变得更强 <br><span class="someFront">在健身房里锻造你的身体</span></h3>
                <p>&ensp;&ensp;&ensp;&ensp;坚持!每天锻炼多坚持一秒，一年360秒。6分钟不能让你变成高帅富，但能改善你的新陈代谢功能，多活几天。
                    每一个优秀的人，都有一段沉默的时光。那一段时光，是付出了很多努力，忍受孤独和寂寞，不抱怨不诉苦，日后说起时，连自己都能被感动的日子。
                </p>
                <a href="browseCourseOptimize.html" class="btn btn-lg btn-pink">现在开始</a>
            </div>
        </div>
    </div>
</section>

</body>
<script src="../jquery/jquery-3.4.1.min.js"></script>
<script src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript">

    jQuery(document).ready(function(){

        let sortIdExit = document.cookie.indexOf("trainersortid");

        if (sortIdExit === -1)
        {
            let sortId = 1;
            $.cookie('trainersortid', sortId);
        }

        let currentSortId = $.cookie("trainersortid");

        $("#inputSortType").val(currentSortId);

        if (currentSortId == 1)
        {
            jQuery.post("/getTrainersListOrderByExperience",function(rst){//处理响应的结果
                writeHTML(rst);
            },"json");//表示返回数据的格式
        }else if (currentSortId == 2){
            jQuery.post("/getTrainersListOrderByAge",function(rst){//处理响应的结果
                writeHTML(rst);
            },"json");//表示返回数据的格式
        }
        else if (currentSortId == 3){
            jQuery.post("/getTrainersListBySex", {"trainerSex": "男"}, function(rst){//处理响应的结果
                writeHTML(rst);
            },"json");//表示返回数据的格式
        }else {
            jQuery.post("/getTrainersListBySex", {"trainerSex": "女"}, function(rst){//处理响应的结果
                writeHTML(rst);
            },"json");//表示返回数据的格式
        }
    });

    function writeHTML(rst){
        let body="";
        for(let i = 0; i < rst.length; i++)
        {
            let json = rst[i];

            body += "<div class=\"col-lg-3 col-md-6 col-sm-6 col-ms-6\">";
            body += "<div class=\"item matchHeight\">";
            body += "<a class=\"photo\" onclick='goTrainerDetail(\""+json.trainerPhone+"\")'>";
            let trainerPhoto = json.trainerImage;
            body += "<img class=\"full-width\" src=\"" +trainerPhoto + "\" alt=\"Coach\">";
            body += "</a>";
            body += "<div class=\"descr someFront\">";
            body += "<a href='#' class='header'><span>"+json.trainerName+"</span></a>";

            body += "年龄: <strong>" + json.trainerAge + "</strong><br>";
            body += "性别: <strong>" + json.trainerSex + "</strong><br>";
            body += "执教经验: <strong>" + json.trainerExperience + "年</strong><br>";
            body += "</div>";
            body += "<div class=\"bottom\">";
            body += "<a href=\"#\" class=\"social-twitter fa fa-twitter\"></a>";
            body += "<a href=\"#\" class=\"social-fb fa fa-facebook\"></a>";
            body += "<a href=\"#\" class=\"social-inst fa fa-instagram\"></a>";
            body += "</div>";
            body += "</div>";
            body += "</div>";
        }
        jQuery("#trainerPlace").html(body);
    }

    $("#inputSortType").click(function (){

        setTimeout("temp()", 2000);

    })

    function temp(){
        let options = $("#inputSortType option:selected");
        let id = options.val();
        $.removeCookie("trainersortid", {path: '/'});
        $.cookie("trainersortid", id);
        window.location.reload();
    }


    function goTrainerDetail(phone){
        $.cookie('currentTrainerPhone', phone);
        window.location.replace("trainerDetails.html");
    }

</script>
</html>

<style type="text/css">
    .someFront{
        color: rgb(250,98,15);
    }
    .someFront1{
        font-family: 微软雅黑, "Microsoft YaHei";
        font-size: 20px;
        color: rgb(250,98,15);
        border:none;
    }
</style>